package thread;

/**
 * 获取线程常用信息的一组方法
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        //以主线程为例，获取其信息
        Thread main = Thread.currentThread();

        String name = main.getName();
        System.out.println(name);

        long id = main.getId();
        System.out.println("唯一标识:"+id);

        int priority = main.getPriority();
        System.out.println("优先级:"+priority);

        boolean isAlive = main.isAlive();
        System.out.println("是否活着:"+isAlive);

        boolean isDaemon = main.isDaemon();
        System.out.println("是否为守护线程:"+isDaemon);

        boolean isInterrupted = main.isInterrupted();
        System.out.println("是否被中断:"+isInterrupted);
    }
}
